﻿#ifndef RANDOMSTRING_H
#define RANDOMSTRING_H

#include <QVector>
#include<random>


/**
 * @brief The RandomString class 用来生成随机字符串，可以指定随机字符串里包含哪些字符
 */
class RandomString
{
public:
    RandomString();
    RandomString(unsigned int seed);
    /**
     * @brief randn 返回一个有 N 个字符的随机字符串
     * @param N 字符串的长度
     * @return
     */
    QString randn(int N);
    void resetCharSet();
    void addChar(QChar c);
    void addCharSet(QVector<QChar> set);
    enum CHARSET {number, lowercase, uppercase};
    void addCharSet(CHARSET set);
    void addCharSet(QString set);
private:
    QVector<QChar> m_charSet;

    static QVector<QChar> m_number;
    static QVector<QChar> m_lowercase;
    static QVector<QChar> m_uppercase;

    std::random_device randomDevice;
    std::mt19937 randomGenerator;
};

#endif // RANDOMSTRING_H
